<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<style type="text/css">
  /*div#rMenu {
      position: absolute;
      visibility: hidden;
      padding: 2px;
      font-size: 14px;
  }

  div#rMenu ul {
      min-width: 50px;
  }*/
  div#rMenu {
      position: absolute;
      visibility: hidden;
      text-align: left;
      padding: 2px;
      width: auto;
      border: 1px
  }

  .dropdown-menu {
      background-color: #ffffff;
      border: 1px solid #ddd;
      box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);
      display: none;
      float: left;
      font-family: "Segoe UI", Helvetica, Arial, sans-serif;
      font-size: 14px;
      left: 0;
      list-style: outside none none;
      margin: 0;
      padding: 5px;
      position: absolute;
      text-shadow: none;
      top: 100%;
      z-index: 1000;
      min-width: 90px;
  }

  .dropdown-menu > li > a {
      clear: both;
      color: #333;
      display: block;
      font-weight: 400;
      line-height: 1.42857;
      padding: 3px 10px;
      white-space: nowrap;
  }

  .ztree li {
      padding: 0;
      margin: 0;
      list-style: none;
      line-height: 20px;
      text-align: left;
      white-space: nowrap
  }

  .ztree li span {
      margin-right: 2px;
      font-weight: lighter;
      font-size: 14px;
      color: #000;
      font-family: inherit;
  }
</style>
<section class="content-header" style="">
  <h1>
    文件管理
    <small>文件的管理页面</small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
    <li><a href="#">系统管理</a></li>
    <li class="active">文件管理</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
        <div class="box-body">
          <div class="col-xs-12 col-sm-9">
            <div class="panel panel-default">
              <div class="panel-heading">文件管理</div>
              <div class="panel-body">
                <form class="form-horizontal" onsubmit="return false;" enctype="multipart/form-data" id="editForm">
                  <div class="form-group">
                    <label class="col-sm-2 control-label" for="type"><span class="asterisk">*</span>资源类型:</label>
                    <div class="col-sm-10">
                      <select class="form-control" name="path" id="type">
                        <option th:each="path : ${paths}" th:value="${path.url}" th:text="${path.name}">上传目录不存在</option>
                      </select>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="eidtPriority" class="col-sm-2 control-label">选择文件</label>
                    <div class="col-sm-10">
                      <input type="file" class="form-control" name="file" id="eidtPriority" placeholder="">
                    </div>
                  </div>
                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10 text-right">
<!--                      <button type="submit" form="editForm" class="btn btn-primary"-->
<!--                              data-action="{type:'submit',form:'#editForm',url:'@{/files/upload}',after:'$.myAction.refreshContent'}">-->
<!--                        保存-->
<!--                      </button>-->
                      <button type="submit" form="editForm" class="btn btn-primary">
                          保存
                      </button>
                      <button type="reset" class="btn btn-warning">重置</button>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</section>
<script>
  $(document).ready(function() {
    $('#editForm').on('submit', function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        $.ajax({
            url: '/ocom_admin/files/upload',
            type: 'POST',
            data: formData,
            contentType: false,
            processData: false,
            success: function(response) {
               if (response.code == 200) {
                    alert("上传成功")
            } else {
                alert(response.msg)
            }
            },
            error: function(error) {
                 alert('文件上传失败，请检查网络或重试！');
            }
        });
    });
});
</script>
</html>